﻿using Wizard.Runtime;
using Wizard.Source;

namespace Wizard.Statements
{
    using Wizard.Runtime;

    [Statement("If then else Statement")]
    internal class If : Statement
    {
        [Field] public bool Condition;
        [Block("then Block")] public IBlockSource Then;
        [Block("else Block")] public IBlockSource Else;

        public override void OnRun(IStatementArgs args, RunArgs runArgs)
        {
            base.OnRun(args, runArgs);
            runArgs.RunResult = RunResult.GoSub;

            runArgs.Sub = (Condition ? Then : Else);
        }

        //protected override void OnEnter(StatementInstance statementInstance)
        //{
        //    statementInstance.Gosub = (mCondition ? mThenBlock : mElseBlock);
        //}
    }
}